<?php
/**
 * 记录相关的数据
 */
class PublicController extends YzwController{
	//错误页面
	public function actionError(){
		set_time_limit(0);
		for ($i=0; $i < 50; $i++) { 
			$datas = RedisCluster::getInstance()->pop('public_error');
			if(!$datas){
				break;
			}
			$model = new ErrorLogModel;
			$model->attributes = $data;
			$model->save(false);
		}

	}


    public function actionSlow(){
        set_time_limit(0);
        $cache = yii::app()->cache->get('WarningController_actionSlow');
        if(!empty($cache)){
            echo '正在锁定';
            exit;
        }else{
            yii::app()->cache->set('WarningController_actionSlow', true, 60);
        }
        $intCount = 50;
        for($i = 1;$i<=$intCount;$i++){

            $arrData = RedisCluster::getInstance()->pop('slow_record');
            if (empty($arrData)) {
                yii::app()->cache->delete('WarningController_actionSlow');
                echo '执行完,没有记录</br>'; 
                return;               
            }else{
                $objModel = new SlowModel();   
                $objModel->attributes = $arrData;
                $objModel->save(false);
                echo "第{$i}次成功添加</br>";   
            }                       
        }
        yii::app()->cache->delete('WarningController_actionSlow');
        echo '执行完成</br>';
        exit;        
    }

	
}